<?php

namespace app\admin\validate\order;

use think\Validate;

class Order extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
        'ids|标识' => 'require|array',
        'id|参数' => 'require|>:0',
        'order_number|订单号码' => 'alphaDash|max:60',
        'payment_status|支付状态' => 'number',
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [];

    /**
     * 定义场景
     * @var []
     */
    protected $scene = [
        'delete' => ['id'],
        'destory' => ['ids'],
    ];

    /**
     * 定义新增场景验证
     * @return $this
     */
    public function sceneIndex()
    {
        $config = config('field.order.payment_status');
        return $this->only(['order_number','payment_status'])
            ->append('payment_status', 'in:'.implode(',', array_keys($config)));
    }

}
